package com.top10.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.top10.common.DatabaseConst;
import com.top10.entity.Admin;
import com.top10.mapper.AdminMapper;
import com.top10.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

	@Autowired
	private AdminMapper adminMapper;

	@Override
	public String getPassword(String phoneNumber)throws Exception{
		Admin admin=new Admin();
		admin.setAccount(phoneNumber);
		return adminMapper.selectthree(admin.getAccount());
	}

	@Override
	public String getAccount(String uuid)throws Exception{
		return adminMapper.selectfour(uuid);
	}

	@Override
	public String getAdmin(String phoneNumber)throws Exception{
		Admin admin=new Admin();
		admin.setAccount(phoneNumber);
		return adminMapper.selecttwo(admin.getAccount());
		/*EntityWrapper<Admin> entityWrapper = new EntityWrapper<>();
		entityWrapper.eq("account",phoneNumber);*/
		/*List<Admin> adminList = adminMapper.selectList(new EntityWrapper<>(admin));
		System.out.println(adminList);*/
//		return null;
//		return adminMapper.selecttwo(admin.getAccount());
	}
	@Override
	public Integer insert(Admin admin)throws Exception{
		return adminMapper.insert(admin);
	}

	@Override
	public  Integer update(Admin admin){
		return adminMapper.update(admin,new EntityWrapper<Admin>().eq("account",admin.getAccount()));
	}
}
